<?php
session_start();
if ( isset($_SESSION['datos_admin']['estado']) )
{
 // ya se ha pasado por el login
echo "ya has iniciado una sesi�n...";
echo "<script type=\"text/javascript\">
 history.go(-1);
 </script>";
} 
else // no se ha pasado por login
{ 

include("header.php");
include(XOOPS_ROOT_PATH."/header.php");
$mydirname = basename( dirname( __FILE__ ) ) ;
	
/* $myts =& MyTextSanitizer::getInstance();
$module_id = $xoopsModule->getVar('mid');

if (is_object($xoopsUser)) {
    $groups = $xoopsUser->getGroups();
} else {
	$groups = XOOPS_GROUP_ANONYMOUS;
}

$gperm_handler =& xoops_gethandler('groupperm');

if (isset($_POST['item_id'])) {
    $perm_itemid = intval($_POST['item_id']);
} else {
    $perm_itemid = 0;
}
//If no access
if (!$gperm_handler->checkRight("resume_submit", $perm_itemid, $groups, $module_id)) {
    redirect_header(XOOPS_URL."/user.php", 3, _NOPERM);
    exit();
} */

    global $xoopsDB, $xoopsConfig, $xoopsUser, $xoopsTheme, $xoopsLogger, $xoopsModule, $xoopsModuleConfig, $mydirname;

	$token = $GLOBALS['xoopsSecurity']->createToken();
	include_once (XOOPS_ROOT_PATH."/modules/$mydirname/include/functions.php");
	
	include_once (XOOPS_ROOT_PATH."/class/xoopstree.php");
	
// Detecci�n de errores
     echo "<script type=\"text/javascript\">
           function verify() {
                var msg = \""._VALIDREGISTRO."\\n__________________________________________________\\n\\n\";
                var errors = \"FALSE\";

                if (document.add.login.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDUSUARIO."\\n\";
                } 
				if (document.add.clave.value == \"\") {
                        errors = \"TRUE\";
                        msg += \""._VALIDCONTRASENA."\\n\";
                }
				
                if (errors == \"TRUE\") {
                        msg += \"__________________________________________________\\n\\n"._VALIDREGISTRO2."\\n\";
                        alert(msg);
                        return false;
                }
          }
          </script>";
		  
  	  echo "<script type=\"text/javascript\">
	 function numeros(e) {
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; 
    patron =/\d/; 
    te = String.fromCharCode(tecla); 
    return patron.test(te);
    } 
      </script>"; 
	  
            echo "<b><center>"._REGISTRO_EMPRESAS."</b><br /><br /></center>";
////////////			
            echo "<fieldset><legend style='font-weight: bold; color: #3366CC;'>"._EMPRESAS_INDEX."</legend>";
			echo "<table width='50%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'>\n";
		    echo "<br /><br />"._INFO_REG_EMP."<br /><br />
			</table>";
			echo "<br><b><center>"._NEW_EMPRESA."</b>";
			echo "<br><b><a href=\"empresas.php\"><img src=\"images/avatar.gif\" border=0 alt=\""._REG_EMPRESA."\" /><br>"._REG_EMPRESA."</b></center></a>";
            echo "</fieldset><br /><br>"; 
//////////////
		
//////////////						
			echo "<fieldset><legend style='font-weight: bold; color: #3366CC;'>"._REGISTRE_EMP."</legend>";			
			echo "<form method=\"post\" action=\"validacion.php\" enctype=\"multipart/form-data\" name=\"add\" onsubmit=\"return verify();\">";
					
			echo "<center>"._INGRESO."</center><br>";		  
			echo "<table width='50%' class='outer' cellspacing='1'>
			<tr>
			<td width='35%' class='even'><b>"._LOGIN_EMPRESA."</b> </td><td class='even'><input type=\"text\" name=\"login\" size=\"20\" maxlength=\"12\" onKeypress=\"return numeros(event);\" /></td>
			</tr><tr>
			<td width='35%' class='odd'><b>Contrase&ntilde;a (S&oacute;lo n&uacute;meros): </b></td><td class='odd'><input type=\"password\" name=\"clave\" size=\"20\" maxlength=\"12\" onKeypress=\"return numeros(event);\">
            </td></tr>";
					
	        $time = time();

	        echo "</table><br />";
			echo "<input type=\"hidden\" name=\"token\" value=\"$token\" />								
			<input type=\"hidden\" name=\"date\" value=\"$time\" />
			<center><input type=\"submit\" value=\""._INGRESAR."\" onClick=\"self.location.href='validacion.php'\" /></center>";
			echo "</form>";
			echo "</fieldset><br /><br>"; 
/////////////////				
				echo "<fieldset><legend style='font-weight: bold; color: #3366CC;'>"._RECUPERAR_PASS."</legend>";	
				echo "<br>"._RECUPERAR_PASS2."";	
				echo "</fieldset><br />"; 	
				
				echo "<br /><br />
<div align=\"center\">" . _INFO_PAG . "</div>
<br /><br />";
				   	
include(XOOPS_ROOT_PATH."/footer.php");
}
?>
